package com.banyuan.lesson.输入输出流;

import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class TestBufferedOutStream {
    public static void main(String[] args) {
        try(BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("bbb.txt"))) {
            //这一步并不会write到硬盘，而是写到缓冲区；
            bos.write("sdfafsada".getBytes());
            //手动刷新缓存区；
            bos.flush();
            //close会自动刷新缓存区，建议手动刷新缓存区，避免数据过多导致传输效率变慢；
            bos.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
